<template>
    <div>
            <!--导航栏-->
            <el-page-header @back="back" :content="content">
            </el-page-header>
            <el-form ref="form" class="edit-el-form" label-position="right" size="small" :model="form" :rules="rules" label-width="auto">
                <el-row :gutter='12'>
                  <el-col :span='11'>
                    <el-form-item label="所属社区" prop="c_id">
                        <el-select v-model="form.c_id" @change="handleComChange" placeholder="请选择社区">
                            <el-option
                                    v-for="item in basic_data"
                                    :key="item.c_id"
                                    :label="item.c_name"
                                    :value="item.c_id">
                            </el-option>
                        </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span='11'>
                    <el-form-item label="所属网格" prop="g_id">
                        <el-select v-model="form.g_id" placeholder="请选择网格">
                            <el-option
                                    v-for="item in allgridlist"
                                    :key="item.g_id"
                                    :label="item.g_name"
                                    :value="item.g_id">
                            </el-option>
                         </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
              <el-row :gutter='12'>
                  <el-col :span='11'>
                    <el-form-item label="有无房" prop="has_house">
                        <el-radio border v-model='form.has_house' label="0">无</el-radio>
                        <el-radio border v-model='form.has_house' label="1">有</el-radio>
                    </el-form-item>
                  </el-col>
                  <el-col :span='11'>
                    <el-form-item label="选择房屋" prop="h_id">
                        <el-select v-model="form.h_id" filterable placeholder="请选择">
                            <el-option
                                    v-for="item in allhouselist"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter='12'>
                  <el-col :span='6'>
                    <el-form-item label="门牌号" prop="room_num">
                        <el-input v-model="form.room_num"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span='5'>
                    <el-form-item label="住房面积" prop="residence_area">
                        <el-input v-model="form.residence_area">
                          <template slot="append">㎡</template>
                        </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span='11'>
                    <el-form-item label="姓名" prop="name">
                        <el-input v-model="form.name"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter='12'>
                  <el-col :span='11'>
                    <el-form-item label="性别" prop="gender">
                         <el-radio border v-model='form.gender' label="1">男</el-radio>
                         <el-radio border v-model='form.gender' label="2">女</el-radio>
                    </el-form-item>
                  </el-col>
                  <el-col :span='11'>
                    <el-form-item label="身份号码" prop="id_card">
                        <el-input v-model="form.id_card"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter='12'>
                  <el-col :span='11'>
                      <el-form-item label="出生日期" prop="birth_day">
                          <el-date-picker
                                v-model="form.birth_day"
                                type="date"
                                value-format="yyyy-MM-dd"
                                placeholder="选择日期">
                          </el-date-picker>
                      </el-form-item>
                  </el-col>
                  <el-col :span='11'>
                      <el-form-item label="民族" prop="nation">
                          <el-select v-model="form.nation" placeholder="请选择">
                              <el-option
                                      v-for="(item,index) in allnations"
                                      :key="index"
                                      :label="item"
                                      :value="index">
                              </el-option>
                          </el-select>
                      </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter='12'>
                  <el-col :span='11'>
                    <el-form-item label="婚姻状况" prop="marry_remark">
                        <el-select v-model="form.marry_remark" @change="handlechangemarry" placeholder="请选择">
                            <el-option
                                    v-for="item in allmarryremark"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col v-if="showMarryDate" :span='11'>
                    <el-form-item label="结婚日期" prop="marry_date">
                        <el-date-picker
                              v-model="form.marry_date"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="选择日期">
                        </el-date-picker>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter='12'>
                  <el-col :span='11'>
                    <el-form-item label="政治面貌" prop="politics_face">
                        <el-select v-model="form.politics_face" placeholder="请选择">
                            <el-option
                                    v-for="item in allpoliticsface"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span='11'>
                    <el-form-item label="学历" prop="educational">
                        <el-select v-model="form.educational" placeholder="请选择">
                            <el-option
                                    v-for="item in alleducational"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter='12'>
                  <el-col :span='11'>  <!-- 增加人员类别 -->
                    <el-form-item label="人员类别" prop="person_type">
                       <el-select v-model="form.person_type" clearable>
                           <el-option
                                   v-for="item in allpersontype"
                                   :key="item.value"
                                   :label="item.label"
                                   :value="item.value">
                           </el-option>
                       </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span='11'>
                    <el-form-item label="特殊人群" prop="special_type">
                       <el-select v-model="form.special_type" @change="changeSpecialType" placeholder="是否特殊人群">
                           <el-option
                                   v-for="item in special_type"
                                   :key="item.value"
                                   :label="item.label"
                                   :value="item.value">
                           </el-option>
                       </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row v-if="showCrimeInfo" :gutter='12'>
                    <el-col :span='11'>
                        <el-form-item label="释解日期" prop="freedom_date">
                            <el-date-picker
                                  v-model="form.freedom_date"
                                  type="date"
                                  value-format="yyyy-MM-dd"
                                  placeholder="选择日期">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span='11'>
                      <el-form-item label="罪名" prop="crime_name">
                          <el-input v-model="form.crime_name"></el-input>
                      </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter='12'>
                  <el-col :span='11'>
                    <el-form-item label="家庭关系" prop="family_relation">
                        <el-select v-model="form.family_relation" no-match-text="无匹配数据" placeholder="请选择" required>
                            <el-option
                                    v-for="item in familyrelations"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span='11'>
                    <el-form-item label="曾用名" prop="used_name">
                        <el-input v-model="form.used_name"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter='12'>
                  <el-col :span='11'>
                    <el-form-item label="管理类型" prop="manage_type">
                        <el-select v-model="form.manage_type" placeholder="请选择">
                            <el-option
                                    v-for="item in allmanagetype"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span='11'>
                    <el-form-item label="籍贯" prop="birth_place">
                        <DistPicker :dist="dist" :catchProvince="catchProvince" :catchCity="catchCity" :catchArea="catchArea"></DistPicker>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter='12'>
                  <el-col :span='11'>
                    <el-form-item label="户籍地" prop="residence_place">
                       <DistPicker :dist="residence_dist" :catchProvince="catchResidenceProvince" :catchCity="catchResidenceCity" :catchArea="catchResidenceArea"></DistPicker>
                    </el-form-item>
                  </el-col>
                  <el-col :span='11'>
                    <el-form-item label="户籍详址" prop="residence_address">
                        <el-input v-model="form.residence_address"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter='12'>
                  <el-col :span='11'>
                    <el-form-item label="现住地" prop="current_live_place">
                        <DistPicker :dist="live_dist" :catchProvince="catchLiveProvince" :catchCity="catchLiveCity" :catchArea="catchLiveArea"></DistPicker>
                    </el-form-item>
                  </el-col>
                  <el-col :span='11'>
                    <el-form-item label="现住详址" prop="current_live_address">
                        <el-input v-model="form.current_live_address"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter='12'>
                  <el-col :span='11'>
                    <el-form-item label="人户一致" prop="person_house_match">
                        <el-select v-model="form.person_house_match" placeholder="请选择">
                            <el-option label="一致" value="1"></el-option>
                            <el-option label="不一致" value="2"></el-option>
                        </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span='11'>
                    <el-form-item label="户籍类别" prop="residence_type">
                        <el-select v-model="form.residence_type" placeholder="请选择">
                            <el-option
                                    v-for="item in allresidencetype"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter='12'>
                  <el-col :span='11'>
                    <el-form-item label="宗教信仰" prop="religion_belief">
                        <el-select v-model="form.religion_belief" placeholder="请选择">
                            <el-option
                                    v-for="item in allreligionbelief"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span='11'>
                    <el-form-item label="联系方式" prop="contact_tel">
                        <el-input v-model="form.contact_tel"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>

                <el-row :gutter='12'>
                    <el-col :span='11'>
                      <el-form-item label="血型" prop="blood_type">
                          <el-select v-model="form.blood_type" placeholder="请选择">
                              <el-option
                                      v-for="item in allbloodtype"
                                      :key="item.value"
                                      :label="item.label"
                                      :value="item.value">
                              </el-option>
                          </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span='11'>
                      <el-form-item label="健康状况" prop="health_remark">
                          <el-select v-model="form.health_remark" placeholder="请选择">
                              <el-option
                                      v-for="item in allhealthremark"
                                      :key="item.value"
                                      :label="item.label"
                                      :value="item.value">
                              </el-option>
                          </el-select>
                      </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter='12'>
                  <el-col :span='11'>
                    <el-form-item label="工作单位" prop="work_company">
                        <el-input v-model="form.work_company"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span='11'>
                    <el-form-item label="职业" prop="job">
                        <el-input v-model="form.job"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter='12'>
                  <el-col :span='11'>
                    <el-form-item label="职务" prop="work_duty">
                        <el-input v-model="form.work_duty"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span='11'>
                    <el-form-item label="兵役状况" prop="military_service_remark">
                        <el-select v-model="form.military_service_remark" placeholder="请选择">
                            <el-option
                                    v-for="item in allmilitartserviceremark"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter='12'>
                  <el-col :span='11'>
                    <el-form-item label="身高" prop="height">
                        <el-input v-model="form.height">
                          <template slot="append">cm</template>
                        </el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                   <el-form-item label="备注" prop="remark">
                        <el-input type="textarea" v-model="form.remark"></el-input>
                   </el-form-item>
                </el-row>
                <!--查看不展示按钮-->
                <el-form-item v-if="edit_type!=0">
                    <el-button type="primary" @click="submitForm('form')" :loading="loading">{{button_name}}</el-button>
                    <el-button @click="back">取消</el-button>
                </el-form-item>
            </el-form>
    </div>
</template>

<script>
    import { getPersonInfo,editPerson,getAllNations } from '@/api/person.js'
    import { getAllPersonType } from '@/api/persontype.js';
    import { getBasicData } from '@/api/basicdata.js';
    import { getAllHouseList } from '@/api/house.js';
    import DistPicker from '@/components/DistPicker.vue';
    export default {
        name:'PersonEdit',
        components:{DistPicker},
        data() {
            let validateNumber=(rule,value,callback)=>{
               if(value==''){
                  callback();
               }
               let float_reg=/^([0-9]{1,}[.][0-9]*)$/;   //校验小数
               let int_reg=/^([0-9]{1,})$/;     //校验整数
               let number_arr={
                  height:'身高',
                  residence_area:'住房面积'
               };
               let rule_name=number_arr[rule.field];
               if(!int_reg.test(value) && !float_reg.test(value)){
                  callback(new Error(rule_name+'必须为数字'));
               }else{
                  callback();
               }
            }
            return {
                form: {
                    c_id:'',
                    g_id:'',
                    has_house:'1',
                    person_type:'',
                    name: '',
                    special_type:'',
                    crime_name:'',
                    freedom_date:'',
                    h_id:'',
                    family_relation:'',
                    used_name:'',
                    gender:'1',
                    id_card:'',
                    birth_day:'',
                    nation:'',
                    manage_type:'',
                    birth_place:'',
                    marry_remark:'',
                    marry_date:'',
                    politics_face:'',
                    educational:'',
                    religion_belief:'',
                    job:'',
                    contact_tel:'',
                    person_house_match:'',
                    residence_place:'',
                    residence_address:'',
                    current_live_place:'',
                    current_live_address:'',
                    health_remark:'',
                    work_company: '',
                    work_duty:'',
                    blood_type:'',
                    military_service_remark:'',
                    residence_type:'',
                    height:'',
                    residence_area:'',
                    room_num:'',
                    remark:''
                },
                dist:{
                    province:'',
                    city:'',
                    area:''
                },
                residence_dist:{
                    province:'',
                    city:'',
                    area:''
                },
                live_dist:{
                    province:'',
                    city:'',
                    area:''
                },
                //校验规则
                rules:{
                    name: [
                        { required:true , message:'请输入人员姓名',trigger:'blur' }
                    ],
                    c_id:[
                        { required:true , message:'请选择所属社区'}
                    ],
                    g_id:[
                        { required:true , message:'请选择所属网格'}
                    ],
                    h_id:[
                       { required:true , message:'请选择是否有房'}
                    ],
                    birth_day:[
                        { type:'string',required:true , message:'请选择出生日期'}
                    ],
                    marry_remark:[
                        { required:true , message:'请选择婚姻状况'}
                    ],
                    politics_face:[
                        { required:true , message:'请选择政治面貌'}
                    ],
                    educational:[
                        { required:true , message:'请选择学历'}
                    ],
                    religion_belief:[
                        { required:true , message:'请选择宗教信仰'}
                    ],
                    contact_tel:[
                        { required:true , message:'请输入联系方式'}
                    ],
                    current_live_address:[
                        { required:true , message:'请输入现住详址'}
                    ],
                    work_company:[
                        { required:true , message:'请输入工作单位'}
                    ],
                    special_type:[
                        { required:true , message:'请选择是否特殊人群'}
                    ],
                    family_relation:[
                        { required:true , message:'请选择与户主关系'}
                    ],
                    id_card:[
                        { required:true , message:'请输入身份证号'}
                    ],
                    nation:[
                        { required:true , message:'请选择民族'}
                    ],
                    manage_type:[
                        { required:true , message:'请选择管理类型'}
                    ],
                    height:[
                        { required:false , validator:validateNumber }
                    ],
                    residence_area:[
                        { required:false , validator:validateNumber }
                    ]
                },
                //加载组件
                loading: false,
                button_name:'立即提交',
                content:'人口信息添加',
                showCrimeInfo:false,
                showMarryDate:false,
                special_type:this.$store.getters.getSpecialType,
                familyrelations:this.$store.getters.getFamilyRelations,
                allmanagetype:this.$store.getters.getAllManageType,
                allmarryremark:this.$store.getters.getAllMarryRemark,
                allpoliticsface:this.$store.getters.getAllPoliticsFace,
                alleducational:this.$store.getters.getAllEducational,
                allreligionbelief:this.$store.getters.getAllReligionBelief,
                alljobtype:this.$store.getters.getAllJobType,
                allhealthremark:this.$store.getters.getAllHealthRemark,
                allbirthcontrolmethod:this.$store.getters.getAllBirthControlMethod,
                allsocietyduty:this.$store.getters.getAllSocietyDuty,
                allskilledin:this.$store.getters.getAllSkilledIn,
                allbloodtype:this.$store.getters.getAllBloodType,
                allmilitartserviceremark:this.$store.getters.getAllMilitaryServiceRemark,
                allresidencetype:this.$store.getters.getAllResidenceType,
                allgridlist:[],
                allnations:[],
                basic_data:[],
                allhouselist:[],
                allpersontype:[]
            }
        },
        methods: {
            submitForm(formName){
                let that = this;
                    this.$refs[formName].validate((valid) => {
                            if (valid) {
                                //校验结婚状态和日期
                                if(this.form.marry_remark!=1 && this.form.marry_remark!=5 && this.form.marry_date==''){
                                   this.$message({
                                       message:'请选择结婚日期',
                                       type:'error',
                                       duration:1000,
                                   });
                                   return false;
                                }
                                //校验释解日期
                                if(this.form.special_type>1 && this.form.freedom_date==''){
                                   this.$message({
                                       message:'请选择释解日期',
                                       type:'error',
                                       duration:1000,
                                   });
                                   return false;
                                }
                                //户籍地必填
                                if(that.residence_dist.province=='' || that.residence_dist.city=='' || that.residence_dist.area==''){
                                    this.$message({
                                        message:'请选择完整的户籍地',
                                        type:'error',
                                        duration:1000,
                                    });
                                    return false;
                                }
                                //籍贯必填
                                if(that.dist.province=='' || that.dist.city=='' || that.dist.area==''){
                                    this.$message({
                                        message:'请选择完整的籍贯',
                                        type:'error',
                                        duration:1000,
                                    });
                                    return false;
                                }
                                //现住地必填
                                if(that.live_dist.province=='' || that.live_dist.city=='' || that.live_dist.area==''){
                                    this.$message({
                                        message:'请选择完整的现住地',
                                        type:'error',
                                        duration:1000,
                                    });
                                    return false;
                                }
                                this.loading=true;
                                this.button_name='正在提交';
                                var send_data={
                                    api_token:this.$store.getters.getSessionId,
                                };
                                //写入表单内容
                                for(let item in this.form){
                                    if(item=='birth_place'){
                                        send_data[item]=that.dist.province+';'+that.dist.city+';'+that.dist.area;
                                    }else if(item=='residence_place'){
                                        send_data[item]=that.residence_dist.province+';'+that.residence_dist.city+';'+that.residence_dist.area;
                                    }else if(item=='current_live_place'){
                                        send_data[item]=that.live_dist.province+';'+that.live_dist.city+';'+that.live_dist.area;
                                    }else{
                                       send_data[item]=this.form[item];
                                    }
                                }
                                if(this.id!=-1){
                                    send_data.id=this.id;
                                }
                                editPerson(send_data).then(function(response){
                                     let code=response.data.code;
                                     let type=code==1?'success':'error';
                                     let msg=code==1?'成功':'失败';
                                     that.$message({
                                         message:that.content+msg,
                                         duration:1200,
                                         type:type,
                                         onClose:function(e){
                                             that.loading=false;
                                             if(code==1){
                                                that.$router.push('/basicdata/personlist');
                                             }else{
                                                that.button_name='立即提交';
                                             }
                                         }
                                    })
                                })
                            }else{
                                setTimeout(()=>{
                                  const is_error=document.getElementsByClassName('is-error');
                                  is_error[0].querySelector('input').focus();
                                },100);
                                return false;
                            }
                    })
            },
            back(){
                this.$router.push({
                   name:'personlist',
                   query:{
                     g_id:this.$store.getters.getCurrentGId
                   }
                });
            },
            handleComChange(c_id){
                this.form.g_id='';
                this.getGridList(c_id);
            },
            getGridList(c_id){
              for(let i=0;i<this.basic_data.length;i++){
                  if(c_id==this.basic_data[i]['c_id']){
                    this.allgridlist=this.basic_data[i]['children'];
                    break;
                  }
              }
            },
            changeSpecialType(e){
                if(e>1){
                  this.showCrimeInfo=true;
                }else{
                  this.showCrimeInfo=false;
                  this.form.crime_name='';
                  this.form.freedom_date='';
                }
            },
            handlechangemarry(e){
               if(e!=1 && e!=5){
                  this.showMarryDate=true;
               }else{
                  this.showMarryDate=false;
                  this.form.marry_date='';
               }
            },
            //地区选择器
            catchProvince(e){
               this.dist.province=e;
            },
            catchCity(e){
              this.dist.city=e;
            },
            catchArea(e){
              this.dist.area=e;
            },
            //户籍地选择
            catchResidenceProvince(e){
               this.residence_dist.province=e;
            },
            catchResidenceCity(e){
               this.residence_dist.city=e;
            },
            catchResidenceArea(e){
               this.residence_dist.area=e;
            },
            //现居地选择
            catchLiveProvince(e){
               this.live_dist.province=e;
            },
            catchLiveCity(e){
               this.live_dist.city=e;
            },
            catchLiveArea(e){
               this.live_dist.area=e;
            },
            getAllHouseList(){
                let send_data={
                    api_token:this.$store.getters.getSessionId
                };
                let that=this;
                getAllHouseList(send_data).then(function(response){
                   that.allhouselist=response.data.list;
                   that.getAllPersonType();
                })
            },
            getAllPersonType(){
                let send_data={
                    api_token:this.$store.getters.getSessionId
                };
                let that=this;
                getAllPersonType(send_data).then(function(response){
                   that.allpersontype=response.data.list;
                   that.getPersonInfo();
                })
            },
            getPersonInfo(){
                if(this.id!=-1){
                   let send_data={
                       api_token:this.$store.getters.getSessionId,
                       id:this.id
                   }
                   let that=this;
                   getPersonInfo(send_data).then(function(response){
                       if(response.data.code==1){
                          let val=response.data.info;
                          let select_arr={
                            h_id:1,
                            special_type:1,
                            family_relation:1,
                            manage_type:1,
                            politics_face:1,
                            marry_remark:1,
                            educational:1,
                            religion_belief:1,
                            person_house_match:1,
                            health_remark:1,
                            blood_type:1,
                            military_service_remark:1,
                            residence_type:1
                          };
                          let number_arr={
                            person_type:1,
                            height:1,
                            residence_area:1
                          };
                          let radio_arr={
                            has_house:1,
                            gender:1,
                          };
                          that.dist={
                            province:val.birth_place_arr[0],
                            city:val.birth_place_arr[1],
                            area:val.birth_place_arr[2]
                          };
                          that.residence_dist={
                            province:val.residence_place_arr[0],
                            city:val.residence_place_arr[1],
                            area:val.residence_place_arr[2]
                          };
                          that.live_dist={
                            province:val.current_live_place_arr[0],
                            city:val.current_live_place_arr[1],
                            area:val.current_live_place_arr[2]
                          };
                          if(val.special_type>1){
                            that.showCrimeInfo=true;
                          }
                          if(val.marry_remark!=1 && val.marry_remark!=5){
                            that.showMarryDate=true;
                          }
                          if(val.c_id>0){
                            that.getGridList(val.c_id);
                          }
                          for(let item in that.form){
                            if(select_arr[item]==1){
                              that.form[item]=val[item]==0?'':val[item].toString();
                            }else if(number_arr[item]==1){
                              that.form[item]=val[item]==0?'':val[item];
                            }else if(radio_arr[item]==1){
                              that.form[item]=val[item].toString();
                            }else{
                              that.form[item]=val[item];
                            }
                          }
                       }
                   })
                }

            }
        },
        created(){
            if(this.edit_type==1){
                this.content='人口信息添加';
            }else if(this.edit_type==0){
                this.content='人口信息详情';
            }else if(this.edit_type==2){
                this.content='人口信息编辑';
            }
            let send_data={
               api_token:this.$store.getters.getSessionId
            };
            let that=this;
            getAllNations(send_data).then(function(response){
               that.allnations=response.data.list;
            })
            getBasicData(send_data).then(function(response){
               that.basic_data=response.data.list;
               that.getAllHouseList();
            })

        },
        computed:{
            id(){
                return this.$route.params.id;
            },
            edit_type(){
                return this.$route.params.edit_type;
            }
        }
    }
</script>

<style>
  .edit-el-form{
      margin-top:30px;
  }
  .el-select{
     width:100%;
  }
  .el-date-editor{
    width:100% !important;
  }
</style>
